package com.example.tony.zyfypt_101yl.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.tony.zyfypt_101yl.R;
import com.example.tony.zyfypt_101yl.bean.LoginBean;
import com.example.tony.zyfypt_101yl.bean.RegisterBean;

import static android.content.Context.MODE_PRIVATE;


/**
 * Created by tony on 2017/5/2.
 */
public class Fragment6 extends Fragment {
    private TextView tvinfo;
    private View view=null;
    private Context context;
    private TextView textname,textrealname,textnumber,text;
    private String username="",phone="";
    private SharedPreferences sp;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        context=getActivity();
        //动态加载Fragment6的布局文件
        view=inflater.inflate(R.layout.fragment6,container,false);
        //获取布局上的控件，注意通过view获取
        textname=(TextView)view.findViewById(R.id.textView5);
        textnumber=(TextView)view.findViewById(R.id.textView7);
        text=(TextView)view.findViewById(R.id.textView);
        sp=context.getSharedPreferences("login",MODE_PRIVATE);
        Toast.makeText(context, "加载我", Toast.LENGTH_SHORT).show();
        readSP();
        textname.setText(username);
        textnumber.setText(phone);


        //返回动态生成的view
        return view;
    }

    private void readSP() {
        username=sp.getString("username",null);
        phone=sp.getString("phone",null);
    }
}
